//
//  BQShopBottomView.m
//  BeeQuick
//
//  Created by student on 2017/7/14.
//  Copyright © 2017年 BecomeRich. All rights reserved.
//

#import "BQShopBottomView.h"
#define KMagin 15

@interface BQShopBottomView ()

@property(nonatomic,weak)UILabel *priceLabel;
@property(nonatomic,weak)  UIButton *selectedButton;

@end

@implementation BQShopBottomView

- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        [self  setupUI];
    }
    return self;
}

- (void)selectedButtonAction{
    if (self.bottomViewBlock != nil) {
        self.bottomViewBlock();
    }
}

- (void)setupUI{
    
    UIButton *selectedButton = [[UIButton alloc]init];
    self.selectedButton = selectedButton;
    selectedButton.backgroundColor = [UIColor yellowColor];
    [selectedButton setTitle:@"选好了" forState:UIControlStateNormal];
    selectedButton.titleLabel.font = [UIFont systemFontOfSize:14];
    [selectedButton  setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [selectedButton addTarget:self action:@selector(selectedButtonAction) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:selectedButton];
    [selectedButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.trailing.bottom.equalTo(self);
        make.width.offset(100);
    }];
    UILabel *showMoneyLabel = [[UILabel alloc]init];
    self.priceLabel = showMoneyLabel;
    showMoneyLabel.backgroundColor = [UIColor whiteColor];
    showMoneyLabel.text = @"共 $ 19.80";
    showMoneyLabel.textColor = [UIColor redColor];
    showMoneyLabel.font = [UIFont systemFontOfSize:14];
    [self addSubview:showMoneyLabel];
    [showMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.equalTo(selectedButton.mas_leading);
        make.top.bottom.equalTo(self);
        make.leading.equalTo(self).offset(KMagin);
    }];
}

- (void)setPrcieLabelText:(NSString *)prcieLabelText{
    
    self.priceLabel.text = prcieLabelText;
}

- (void)setSure:(NSString *)sure{
    
     [self.selectedButton setTitle:sure forState:UIControlStateNormal];
}
@end
